import request from '@/utils/request'

// 获取订单列表
export function getOrderList(params) {
  return request({
    url: '/orders/list',
    method: 'get',
    params
  })
}

// 获取订单详情
export function getOrderDetail(orderId) {
  return request({
    url: `/orders/${orderId}`,
    method: 'get'
  })
}

// 推送订单到ERP
export function pushOrder(data) {
  return request({
    url: '/orders/push',
    method: 'post',
    data
  })
}

// 导出订单
export function exportOrders(params) {
  return request({
    url: '/orders/export',
    method: 'get',
    params,
    responseType: 'blob'
  })
}

// 更新订单状态
export function updateOrderStatus(orderId, data) {
  return request({
    url: `/orders/${orderId}/status`,
    method: 'put',
    data
  })
}

// 获取订单商品列表
export function getOrderGoods(orderId) {
  return request({
    url: `/orders/${orderId}/goods`,
    method: 'get'
  })
}

// 更新订单商品
export function updateOrderGoods(orderId, data) {
  return request({
    url: `/orders/${orderId}/goods`,
    method: 'put',
    data
  })
}

// 取消订单
export function cancelOrder(orderId, data) {
  return request({
    url: `/orders/${orderId}/cancel`,
    method: 'post',
    data
  })
}

// 删除订单
export function deleteOrder(orderId) {
  return request({
    url: `/orders/${orderId}`,
    method: 'delete'
  })
}

// 批量更新订单状态
export function batchUpdateOrderStatus(data) {
  return request({
    url: '/orders/batch/status',
    method: 'put',
    data
  })
}

// 获取订单统计数据
export function getOrderStats(params) {
  return request({
    url: '/orders/stats',
    method: 'get',
    params
  })
} 